Calendar All Tests
Current file: /home/estudydev/workspace/eStudy_svn/web/teams/classes/class.teamartefacts.inc.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
0.00 %0.00%
0.00% 0 / 31
 
TeamArtefacts
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 3
0.00 %0.00%
0.00% 0 / 31
 public function getTeamForItem($cat, $item)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 8
 public function setTeamForItem($cat, $item, $team)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 9
 public function deleteItem($cat, $item)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 14


       1                 : <?php                                                                                                                        
       2                 : /*--------------------------------------------------------------------------+                                                
       3                 :  This file is part of eStudy.                                                                                                
       4                 :  teams/classes/class.teamartefacts.inc.php                                                                                   
       5                 :  - Modulgruppe:  Teams                                                                                                       
       6                 :  - Beschreibung: Verwaltung der Zuordnung von Elementen (Forenbeiträge, Ressourcen...) zu Teams.                            
       7                 :  - Version:      0.1, 26/03/06                                                                                               
       8                 :  - Autor(en):    Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                             
       9                 :  +---------------------------------------------------------------------------+                                               
      10                 :  This program is free software; you can redistribute it and/or                                                               
      11                 :  modify it under the terms of the GNU General Public License                                                                 
      12                 :  as published by the Free Software Foundation; either version 2                                                              
      13                 :  of the License, or any later version.                                                                                       
      14                 :  +---------------------------------------------------------------------------+                                               
      15                 :  This program is distributed in the hope that it will be useful,                                                             
      16                 :  but WITHOUT ANY WARRANTY; without even the implied warranty of                                                              
      17                 :  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                                               
      18                 :  GNU General Public License for more details.                                                                                
      19                 :  You should have received a copy of the GNU General Public License                                                           
      20                 :  along with this program; if not, write to the Free Software                                                                 
      21                 :  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.                                                 
      22                 :  +--------------------------------------------------------------------------*/                                               
      23                 : /**                                                                                                                          
      24                 :  * Verwaltung der Zuordnung von Elementen (Forenbeiträge, Ressourcen...) zu Teams.                                          
      25                 :  * @package eStudy.Teams                                                                                                     
      26                 :  * @version 0.1, 26/03/06                                                                                                    
      27                 :  * @author  Clemens Weiß <clemens.weiss@mni.fh-giessen.de>                                                                  
      28                 :  */                                                                                                                          
      29                 : if(! defined("PATH_TO_ROOT")) define("PATH_TO_ROOT","../../");                                                               
      30                 : // Hier werden die gleichen Konstanten wie im Rollenspiel verwendet, damit es                                                
      31                 : // keine Konflikte gibt, wenn beide Klassen eingebunden werden.                                                              
      32                 : if (!defined("FORUM")) define("FORUM", 1);                                                                                   
      33                 : if (!defined("RESSOURCE")) define("RESSOURCE", 4);                                                                           
      34                 : require_once (PATH_TO_ROOT."teams/classes/class.team.inc.php");                                                              
      35                 :                                                                                                                              
      36                 : class TeamArtefacts {                                                                                                        
      37                 :     /**                                                                                                                      
      38                 :      * Gibt zu einem Element (Forenbeitrag oder Ressource)                                                                   
      39                 :      * das Team zurück.                                                                                                     
      40                 :      *                                                                                                                       
      41                 :      * @static                                                                                                               
      42                 :      * @access public                                                                                                        
      43                 :      * @param int $cat Kategorie, zu der das Element gehört (FORUM - Forumpost,                                             
      44                 :      *            RESSOURCE - Link, Datei oder Ordner im Ressourcenmanager)                                                  
      45                 :      * @param int $item ID des Elements                                                                                      
      46                 :      * @return mixed Teamobjekt oder false                                                                                   
      47                 :      */                                                                                                                      
      48                 :     public function getTeamForItem($cat, $item) {                                                                            
      49               0 :         global $db, $settings;                                                                                               
      50               0 :         $dbp = $settings["dbPrefix"];                                                                                        
      51               0 :         if (strval(intval($cat)) != $cat || strval(intval($item)) != $item) {                                                
      52               0 :             return false;                                                                                                    
      53                 :         }                                                                                                                    
      54               0 :         $teamID = intval($db->get_var("SELECT team_id FROM {$dbp}team_artefacts WHERE category='$cat' AND item_id='$item'"));
      55               0 :         if ($teamID > 0) {                                                                                                   
      56               0 :             return new Team($teamID);                                                                                        
      57                 :         }                                                                                                                    
      58               0 :         return false;                                                                                                        
      59                 :     }                                                                                                                        
      60                 :     /**                                                                                                                      
      61                 :      * Legt für ein Element (Forenbeitrag oder Ressource) fest,                                                             
      62                 :      * dass es vom Mitglied eines Teams erstellt wurde.                                                                      
      63                 :      *                                                                                                                       
      64                 :      * @static                                                                                                               
      65                 :      * @access public                                                                                                        
      66                 :      * @param int $cat Kategorie, zu der das Element gehört (FORUM - Forumpost,                                             
      67                 :      *            RESSOURCE - Link, Datei oder Ordner im Ressourcenmanager)                                                  
      68                 :      * @param int $item ID des Elements                                                                                      
      69                 :      * @param int $team ID des Teams                                                                                         
      70                 :      * @return bool true bei Erfolg, sonst false                                                                             
      71                 :      */                                                                                                                      
      72                 :     public function setTeamForItem($cat, $item, $team) {                                                                     
      73               0 :         global $db, $settings, $EZSQL_ERROR;                                                                                 
      74               0 :         $dbp = $settings["dbPrefix"];                                                                                        
      75               0 :         if (strval(intval($cat)) != $cat || strval(intval($item)) != $item || strval(intval($team)) != $team) {              
      76               0 :             return false;                                                                                                    
      77                 :         }                                                                                                                    
      78               0 :         $errorCount = count($EZSQL_ERROR);                                                                                   
      79               0 :         $db->query("REPLACE INTO {$dbp}team_artefacts SET category='$cat', item_id='$item', team_id='$team'");               
      80               0 :         if (count($EZSQL_ERROR) > $errorCount) {                                                                             
      81               0 :             return false;                                                                                                    
      82                 :         }                                                                                                                    
      83               0 :         return true;                                                                                                         
      84                 :     }                                                                                                                        
      85                 :     /**                                                                                                                      
      86                 :      * Löscht die Teamzuordnungen zu einem oder mehreren angegebenen Elementen.                                             
      87                 :      *                                                                                                                       
      88                 :      * @static                                                                                                               
      89                 :      * @access public                                                                                                        
      90                 :      * @param int $cat Kategorie, zu der das Element gehört (FORUM - Forumpost,                                             
      91                 :      *            RESSOURCE - Link, Datei oder Ordner im Ressourcenmanager)                                                  
      92                 :      * @param mixed $item ID eines Elements (int) oder Array von IDs                                                         
      93                 :      * @return bool true bei Erfolg, sonst false                                                                             
      94                 :      */                                                                                                                      
      95                 :     public function deleteItem($cat, $item) {                                                                                
      96               0 :         global $db, $settings, $EZSQL_ERROR;                                                                                 
      97               0 :         $dbp = $settings["dbPrefix"];                                                                                        
      98               0 :         if (strval(intval($cat)) != $cat || !(strval(intval($item)) == $item || (is_array($item) && !empty($item)))) {       
      99               0 :             return false;                                                                                                    
     100                 :         }                                                                                                                    
     101               0 :         if (is_array($item)) {                                                                                               
     102               0 :             $item = array_map("intval", $item);                                                                              
     103               0 :             $itemSQL = "item_id IN (".implode(", ", $item) .")";                                                             
     104               0 :         } else {                                                                                                             
     105               0 :             $itemSQL = "item_id='$item'";                                                                                    
     106                 :         }                                                                                                                    
     107               0 :         $errorCount = count($EZSQL_ERROR);                                                                                   
     108               0 :         $db->query("DELETE FROM {$dbp}team_artefacts WHERE category='$cat' AND $itemSQL");                                   
     109               0 :         if (count($EZSQL_ERROR) > $errorCount) {                                                                             
     110               0 :             return false;                                                                                                    
     111                 :         }                                                                                                                    
     112               0 :         return true;                                                                                                         
     113                 :     }                                                                                                                        
     114                 : }                                                                                                                            
     115                 :                                                                                                                              

Generated by PHPUnit 3.2.21 and Xdebug 2.0.3 at Thu Nov 26 17:01:15 CET 2009.